




//
//  UseModelTableview.m
//  住房条件帅选器
//
//  Created by MB__Lee on 2018/5/18.
//  Copyright © 2018年 MB__Lee. All rights reserved.
//

#import "UseModelTableview.h"

#define  lastCell_hight 67


@interface UseModelTableview()<BottomViewDelegate>
@property(nonatomic,strong)BottomView *bottom;

@end

static NSString *BottomView_Identi = @"BottomView";
static NSString *BaseTypeCell_Identi = @"BaseTypeCell";
@implementation UseModelTableview
-(BottomView *)bottom{
    if (!_bottom) {
        _bottom = [[NSBundle mainBundle] loadNibNamed:BottomView_Identi owner:nil options:nil].lastObject;
        _bottom.delegate = self;
        
    }
    return  _bottom;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    BaseTypeCell *cell = [tableView dequeueReusableCellWithIdentifier:BaseTypeCell_Identi];
    cell.model = self.sourceMut[indexPath.row];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (indexPath.row == self.sourceMut.count - 1 ) {
        [cell addSubview:self.bottom];
        self.bottom.frame = CGRectMake(0, 0, cell.bounds.size.width, cell.bounds.size.height);
    }else{
        
        for (BottomView *view in cell.subviews) {
            if ([view isKindOfClass:[BottomView class]]) {
                [view removeFromSuperview];
            }
        }
    }
    
    return  cell;
}
-(void)setMinPlaceHolder:(NSString *)minPlaceHolder max:(NSString *)maxPlaceHolder{
    [self.bottom setPlaceHolderMin:minPlaceHolder max:maxPlaceHolder];
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == self.sourceMut.count - 1) {
        return;
    }
    
    if ([self.BaseDelegate respondsToSelector:@selector(BaseTypeTableVeiw:sendModel:)]) {
        
        BaseModel *model = self.sourceMut[indexPath.row];
        [self.BaseDelegate BaseTypeTableVeiw:self sendModel:model];
    }
}

#pragma mark ---BottomView 代理方法
-(void)BottomView:(BottomView *)bottom sendMin:(NSString *)min max:(NSString *)max{
    if ([self.BaseDelegate respondsToSelector:@selector(BaseTypeTableVeiw:sendMin:max:)]) {
        [self.BaseDelegate BaseTypeTableVeiw:self sendMin:min max:max];
    }
}

//重载父类方法 ---未实现---后期改进
-(void)setSourceMut:(NSMutableArray *)sourceMut{
    [super setSourceMut:sourceMut];
    

    
}



@end
